home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 5.0 KB | 228 lines | [TEXT/MPS ] |
- ;
- ; File: 604Performance.s
- ;
- ; Contains: 604 Performance Code
- ;
- ; Written by: dgc = Douglas George Clarke
- ;
- ; Copyright: © 1995 by Apple Computer, Inc., All Rights Reserved.
- ;
-
-
- ;******************************************************************************************
- ;
- ; Macro definitions used throughout the file
- ;
-
- ;
- ; Makecsect - Creates a new program section.
- ;
-
- MACRO
- makecsect &name
-
- csect &name.[pr]
- function &name.[pr]
-
-
- ENDM
-
- ;
- ; Makeexport - Exports the specified name so that other object files can reference it.
- ;
- MACRO
- makeexport &name
-
- &name export &name
-
- ENDM
-
- ;
- ; C_PROLOGUE - Glue code used to set up our environment when we get called from C.
- ;
-
- MACRO
- C_PROLOGUE &spaceToSave
-
- mflr r0 ;get link register
- stw r0,0x0008(SP) ;store the link resgister on the stack
- stwu SP,-&spaceToSave(SP) ;skip over the stack space where the caller
- ; might have saved stuff
- ENDM
-
- ;
- ; C_EPILOGUE - Glue code used to tear down our environment when we return to C.
- ;
-
- MACRO
- C_EPILOGUE &spaceToRestore
-
- lwz r0, 0x8+&spaceToRestore(SP) ;get the saved link register
- addic SP,SP,&spaceToRestore ;reset the stack pointer
- mtlr r0 ;reset the link register
- blr ; return via the link register
-
- ENDM
-
-
- ;******************************************************************************************
- ;
- ; Table of contents (TOC) entries
- ;
-
- tc .G4GetPMC[tc],.G4GetPMC
- tc .G4ClearPMC[tc],.G4ClearPMC
- tc .G4SetMMCR0[tc],.G4SetMMCR0
-
-
- ;******************************************************************************************
- ;
- ; void G4GetPMC( long *PMC1, long *PMC2, long *PMC3, long *PMC4)
- ;
- ; Copy the PMC Registers into the longs pointed at by PMC1 and PMC2
- ;
-
- makecsect .G4GetPMC
- makeexport .G4GetPMC
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- C_PROLOGUE saveSpace
-
- ReadCounters:
- mfspr r7,953
- stw r7,0(r3)
-
- ; mfspr r7,954
- ; stw r7,0(r4)
-
- ; mfspr r7,957
- ; stw r7,0(r5)
-
- ; mfspr r7,958
- ; stw r7,0(r6)
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; void G4ClearPMC( void)
- ;
- ; Clear the PMC1 Registers
- ;
-
- makecsect .G4ClearPMC
- makeexport .G4ClearPMC
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- C_PROLOGUE saveSpace
-
- ClearCounters:
- li r5,0
- mtspr 953,r5
- ; mtspr 954,r5
- ; mtspr 957,r5
- ; mtspr 958,r5
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; void G4SetMMCR0( long MMCR0, long MMRC1, long MMCR2)
- ;
- ; Build the MMCR0 word and store it in the MMCR0
- ;
-
- makecsect .G4SetMMCR0
- makeexport .G4SetMMCR0
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- PMC1Select set r3
- PMC2Select set r4
-
- C_PROLOGUE saveSpace
-
- SetTheMMCRO:
- mtspr 952,r3
-
- ; mtspr 956,r4
-
- ; mtspr 944,r5
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; TVector for InternalFlushCacheRangePPC
- ;
-
- EXPORT G4GetPMC[ds]
- G4GetPMC csect G4GetPMC[ds]
- dc.l .G4GetPMC
- dc.l TOC[tc0]
- dc.l 0
-
- EXPORT G4ClearPMC[ds]
- G4ClearPMC csect G4ClearPMC[ds]
- dc.l .G4ClearPMC
- dc.l TOC[tc0]
- dc.l 0
-
- EXPORT G4SetMMCR0[ds]
- G4SetMMCR0 csect G4SetMMCR0[ds]
- dc.l .G4SetMMCR0
- dc.l TOC[tc0]
- dc.l 0
-
- END
-